(function(){"use strict";BX.namespace("BX.Filter");BX.Filter.Fields=function(t){this.parent=null;this.init(t)};var t=new WeakMap;var e=new WeakMap;BX.Filter.Fields.prototype={init:function(t){this.parent=t;BX.addCustomEvent(window,"UI::Select::change",BX.delegate(this._onDateTypeChange,this))},deleteField:function(t){BX.remove(t)},isFieldDelete:function(t){return BX.hasClass(t,this.parent.settings.classFieldDelete)},isFieldValueDelete:function(t){return BX.hasClass(t,this.parent.settings.classValueDelete)||BX.hasClass(t.parentNode,this.parent.settings.classValueDelete)},isDragButton:function(t){return t&&BX.hasClass(t,this.parent.settings.classPresetDragButton)},clearFieldValue:function(t){if(t){var e=BX.Filter.Utils.getByClass(t,this.parent.settings.classControl,true);var i=BX.Filter.Utils.getByClass(t,this.parent.settings.classSquare,true);(i||[]).forEach(BX.remove);(e||[]).forEach(function(t){t&&"value"in t&&(t.value="")},this)}},getField:function(t){var e;if(BX.type.isDomNode(t)){e=BX.findParent(t,{class:this.parent.settings.classField},true,false);if(!BX.type.isDomNode(e)){e=BX.findParent(t,{class:this.parent.settings.classFieldGroup},true,false)}}return e},render:function(t,e){var i,n,a,r;if(BX.type.isPlainObject(e)&&BX.type.isNotEmptyString(t)){i=Object.keys(e);i.forEach(function(i){r="{{"+i+"}}";t=t.replace(new RegExp(r,"g"),e[i])});a=BX.create("div",{html:t});n=BX.Filter.Utils.getByClass(a,this.parent.settings.classFieldGroup);if(!BX.type.isDomNode(n)){n=BX.Filter.Utils.getByClass(a,this.parent.settings.classField)}if(!BX.type.isDomNode(n)){n=BX.Filter.Utils.getByClass(a,this.parent.settings.classFieldLine)}}return n},createInputText:function(t){var e={block:"main-ui-control-field",mix:this.parent.getParam("ENABLE_LABEL")?[this.parent.settings.classFieldWithLabel]:null,deleteButton:true,valueDelete:true,name:t.NAME,type:t.TYPE,label:this.parent.getParam("ENABLE_LABEL")?t.LABEL:"",dragTitle:this.parent.getParam("MAIN_UI_FILTER__DRAG_FIELD_TITLE"),deleteTitle:this.parent.getParam("MAIN_UI_FILTER__REMOVE_FIELD"),content:[{block:"main-ui-control-string",name:t.NAME,placeholder:t.PLACEHOLDER||"",value:BX.type.isNotEmptyString(t.VALUE)||BX.type.isNumber(t.VALUE)?t.VALUE:"",tabindex:t.TABINDEX}]};return BX.decl(e)},createTextarea:function(t){var e=BX.decl({block:"main-ui-control-field",mix:this.parent.getParam("ENABLE_LABEL")?[this.parent.settings.classFieldWithLabel]:null,deleteButton:true,valueDelete:true,name:t.NAME,type:t.TYPE,label:this.parent.getParam("ENABLE_LABEL")?t.LABEL:"",dragTitle:this.parent.getParam("MAIN_UI_FILTER__DRAG_FIELD_TITLE"),deleteTitle:this.parent.getParam("MAIN_UI_FILTER__REMOVE_FIELD"),content:[{block:"main-ui-control-textarea",name:t.NAME,placeholder:t.PLACEHOLDER||"",value:BX.type.isNotEmptyString(t.VALUE)||BX.type.isNumber(t.VALUE)?t.VALUE:"",tabindex:t.TABINDEX}]});var i=e.querySelector("textarea");var n=function(){BX.style(i,"height","1px");BX.style(i,"height",i.scrollHeight+"px")};BX.bind(i,"input",n);BX.bind(i,"change",n);BX.bind(i,"keyup",n);BX.bind(i,"cut",n);BX.bind(i,"paste",n);return e},createDestSelector:function(t){var e,i;var n={block:"main-ui-control-field",mix:this.parent.getParam("ENABLE_LABEL")?[this.parent.settings.classFieldWithLabel]:null,deleteButton:true,valueDelete:true,name:t.NAME,type:t.TYPE,label:this.parent.getParam("ENABLE_LABEL")?t.LABEL:"",dragTitle:this.parent.getParam("MAIN_UI_FILTER__DRAG_FIELD_TITLE"),deleteTitle:this.parent.getParam("MAIN_UI_FILTER__REMOVE_FIELD"),content:{block:"main-ui-control-entity",mix:"main-ui-control",attrs:{"data-multiple":JSON.stringify(t.MULTIPLE)},content:[]}};if("_label"in t.VALUES&&!!t.VALUES._label){if(t.MULTIPLE){var a=!!t.VALUES._label?t.VALUES._label:[];if(BX.type.isPlainObject(a)){a=Object.keys(a).map(function(t){return a[t]})}if(!BX.type.isArray(a)){a=[a]}var r=!!t.VALUES._value?t.VALUES._value:[];if(BX.type.isPlainObject(r)){r=Object.keys(r).map(function(t){return r[t]})}if(!BX.type.isArray(r)){r=[r]}a.forEach(function(t,e){n.content.content.push({block:"main-ui-square",tag:"span",name:t,item:{_label:t,_value:r[e]}})})}else{n.content.content.push({block:"main-ui-square",tag:"span",name:"_label"in t.VALUES?t.VALUES["_label"]:"",item:t.VALUES})}}n.content.content.push({block:"main-ui-square-search",tag:"span",content:{block:"main-ui-control-string",name:t.NAME+"_label",tabindex:t.TABINDEX,type:"text",placeholder:t.PLACEHOLDER||""}},{block:"main-ui-control-string",name:t.NAME,type:"hidden",placeholder:t.PLACEHOLDER||"",value:"_value"in t.VALUES?t.VALUES["_value"]:"",tabindex:t.TABINDEX});n=BX.decl(n);e=BX.Filter.Utils.getBySelector(n,'.main-ui-control-string[type="text"]');BX.addClass(e,"main-ui-square-search-item");BX.bind(e,"focus",function(t){BX.fireEvent(t.currentTarget,"click")});BX.bind(e,"click",BX.proxy(this._onCustomEntityInputClick,this));if(!this.bindDocument){BX.bind(document,"click",BX.proxy(this._onCustomEntityBlur,this));document.addEventListener("focus",BX.proxy(this._onDocumentFocus,this),true);this.bindDocument=true}BX.bind(e,"keydown",BX.proxy(this._onCustomEntityKeydown,this));BX.bind(n,"click",BX.proxy(this._onCustomEntityFieldClick,this));BX.ready(BX.proxy(function(){BX.Filter.DestinationSelector.create(t.NAME,{filterId:this.parent.getParam("FILTER_ID"),fieldId:t.NAME})},this));return n},createCustomEntity:function(t){var e,i;var n={block:"main-ui-control-field",mix:this.parent.getParam("ENABLE_LABEL")?[this.parent.settings.classFieldWithLabel]:null,deleteButton:true,valueDelete:true,name:t.NAME,type:t.TYPE,label:this.parent.getParam("ENABLE_LABEL")?t.LABEL:"",dragTitle:this.parent.getParam("MAIN_UI_FILTER__DRAG_FIELD_TITLE"),deleteTitle:this.parent.getParam("MAIN_UI_FILTER__REMOVE_FIELD"),content:{block:"main-ui-control-entity",mix:"main-ui-control",attrs:{"data-multiple":JSON.stringify(t.MULTIPLE)},content:[]}};if("_label"in t.VALUES&&!!t.VALUES._label){if(t.MULTIPLE){var a=!!t.VALUES._label?t.VALUES._label:[];if(BX.type.isPlainObject(a)){a=Object.keys(a).map(function(t){return a[t]})}if(!BX.type.isArray(a)){a=[a]}var r=!!t.VALUES._value?t.VALUES._value:[];if(BX.type.isPlainObject(r)){r=Object.keys(r).map(function(t){return r[t]})}if(!BX.type.isArray(r)){r=[r]}a.forEach(function(t,e){n.content.content.push({block:"main-ui-square",tag:"span",name:t,item:{_label:t,_value:r[e]}})})}else{n.content.content.push({block:"main-ui-square",tag:"span",name:"_label"in t.VALUES?t.VALUES["_label"]:"",item:t.VALUES})}}n.content.content.push({block:"main-ui-square-search",tag:"span",content:{block:"main-ui-control-string",name:t.NAME+"_label",tabindex:t.TABINDEX,type:"text",placeholder:t.PLACEHOLDER||""}},{block:"main-ui-control-string",name:t.NAME,type:"hidden",placeholder:t.PLACEHOLDER||"",value:"_value"in t.VALUES?t.VALUES["_value"]:"",tabindex:t.TABINDEX});n=BX.decl(n);e=BX.Filter.Utils.getBySelector(n,'.main-ui-control-string[type="text"]');BX.addClass(e,"main-ui-square-search-item");BX.bind(e,"focus",BX.proxy(this._onCustomEntityInputFocus,this));BX.bind(e,"click",BX.proxy(this._onCustomEntityInputClick,this));if(!this.bindDocument){BX.bind(document,"click",BX.proxy(this._onCustomEntityBlur,this));document.addEventListener("focus",BX.proxy(this._onDocumentFocus,this),true);this.bindDocument=true}BX.bind(e,"keydown",BX.proxy(this._onCustomEntityKeydown,this));BX.bind(n,"click",BX.proxy(this._onCustomEntityFieldClick,this));return n},_onCustomEntityInputFocus:function(t){BX.fireEvent(t.currentTarget,"click")},_onCustomEntityInputClick:function(t){var e,i,n,a;t.preventDefault();t.stopPropagation();if(t.isTrusted){this.trustTimestamp=t.timeStamp;this.notTrustTimestamp=this.notTrustTimestamp||t.timeStamp}else{this.notTrustTimestamp=t.timeStamp}e=new Date(this.trustTimestamp);i=new Date(this.notTrustTimestamp);n=e.getMinutes()+":"+e.getSeconds();a=i.getMinutes()+":"+i.getSeconds();if(n!==a){this._onCustomEntityFocus(t)}},_onDocumentFocus:function(t){var e=this.getCustomEntityInstance();var i=e.getPopupContainer();var n=e.getLabelNode()===t.target;var a=!!i&&i.contains(t.target);if(!n&&!a){this._onCustomEntityBlur(t)}},_onCustomEntityKeydown:function(t){var e=BX.Filter.Utils.getByClass(t.target.parentNode.parentNode,this.parent.settings.classSquare,true);var i=null;if(e.length){i=e[e.length-1]}if(BX.Filter.Utils.isKey(t,"backspace")&&t.currentTarget.selectionStart===0){if(BX.type.isDomNode(i)){if(BX.hasClass(i,this.parent.settings.classSquareSelected)){BX.remove(i);var n=BX.Filter.Utils.getBySelector(t.target.parentNode.parentNode,'input[type="hidden"]');n.value="";BX.fireEvent(n,"input")}else{BX.addClass(i,this.parent.settings.classSquareSelected)}}}else if(BX.type.isDomNode(i)&&BX.hasClass(i,this.parent.settings.classSquareSelected)){BX.removeClass(i,this.parent.settings.classSquareSelected)}},_onCustomEntityFieldClick:function(t){var e;if(BX.hasClass(t.target,this.parent.settings.classSquareDelete)){e=BX.findParent(t.target,{className:this.parent.settings.classSquare},true,false);if(BX.type.isDomNode(e)){var i=this.getCustomEntityInstance();BX.onCustomEvent(window,"BX.Main.Filter:customEntityRemove",[i]);BX.remove(e)}}else{var n=BX.Filter.Utils.getBySelector(t.target,'input[type="text"]');BX.fireEvent(n,"focus")}},_onCustomEntityBlur:function(t){var e={stopBlur:false};BX.onCustomEvent(window,"BX.Main.Filter:onGetStopBlur",[t,e]);if(typeof e.stopBlur=="undefined"||!e.stopBlur){var i=this.getCustomEntityInstance();BX.onCustomEvent(window,"BX.Main.Filter:customEntityBlur",[i]);BX.unbind(i.getPopupContainer(),"click",this._stopPropagation);BX.removeClass(i.getField(),this.parent.settings.classFocus)}},_stopPropagation:function(t){t.stopPropagation()},getCustomEntityInstance:function(){if(!(this.customEntityInstance instanceof BX.Main.ui.CustomEntity)){this.customEntityInstance=new BX.Main.ui.CustomEntity}return this.customEntityInstance},_onCustomEntityFocus:function(t){var e=BX.findParent(t.currentTarget,{className:"main-ui-control-entity"},true,false);var i=this.getCustomEntityInstance();t.stopPropagation();i.setField(e);BX.onCustomEvent(window,"BX.Main.Filter:customEntityFocus",[i]);var n=i.getPopupContainer();if(BX.type.isElementNode(n)){BX.bind(n,"click",this._stopPropagation)}BX.addClass(e,this.parent.settings.classFocus)},createCustom:function(t){var e,i,n;var a=[];t.VALUE=BX.util.htmlspecialcharsback(t.VALUE);a.push("main-ui-control");a.push("main-ui-custom-style");n=BX.decl({block:"main-ui-control-field",mix:this.parent.getParam("ENABLE_LABEL")?[this.parent.settings.classFieldWithLabel]:null,name:t.NAME,type:t.TYPE,deleteButton:true,label:this.parent.getParam("ENABLE_LABEL")?t.LABEL:"",dragTitle:this.parent.getParam("MAIN_UI_FILTER__DRAG_FIELD_TITLE"),deleteTitle:this.parent.getParam("MAIN_UI_FILTER__REMOVE_FIELD"),content:{block:"main-ui-custom",mix:a,attrs:{"data-name":t.NAME},content:""}});i='name="'+t.NAME+'" value="'+("_VALUE"in t?t._VALUE:"")+'"';e=BX.Filter.Utils.getByClass(n,"main-ui-custom");try{t.VALUE=t.VALUE.replace('name="'+t.NAME+'"',i)}catch(t){}BX.html(e,t.VALUE);return n},createSelect:function(t){return BX.decl({block:"main-ui-control-field",mix:this.parent.getParam("ENABLE_LABEL")?[this.parent.settings.classFieldWithLabel]:null,name:t.NAME,type:t.TYPE,deleteButton:true,label:this.parent.getParam("ENABLE_LABEL")?t.LABEL:"",dragTitle:this.parent.getParam("MAIN_UI_FILTER__DRAG_FIELD_TITLE"),deleteTitle:this.parent.getParam("MAIN_UI_FILTER__REMOVE_FIELD"),content:{block:this.parent.settings.classSelect,name:t.NAME,items:t.ITEMS,value:"VALUE"in t?t.VALUE:t.ITEMS[0],params:t.PARAMS,tabindex:t.TABINDEX,valueDelete:false}})},createMultiSelect:function(t){return BX.decl({block:"main-ui-control-field",mix:this.parent.getParam("ENABLE_LABEL")?[this.parent.settings.classFieldWithLabel]:null,name:t.NAME,type:t.TYPE,deleteButton:true,label:this.parent.getParam("ENABLE_LABEL")?t.LABEL:"",dragTitle:this.parent.getParam("MAIN_UI_FILTER__DRAG_FIELD_TITLE"),deleteTitle:this.parent.getParam("MAIN_UI_FILTER__REMOVE_FIELD"),content:{block:"main-ui-multi-select",name:t.NAME,tabindex:"TABINDEX"in t?t.TABINDEX:"",placeholder:!this.parent.getParam("ENABLE_LABEL")&&"PLACEHOLDER"in t?t.PLACEHOLDER:"",items:"ITEMS"in t?t.ITEMS:[],value:"VALUE"in t?t.VALUE:[],params:"PARAMS"in t?t.PARAMS:{isMulti:true},valueDelete:true}})},createCustomDate:function(t){var e={block:"main-ui-control-field-group",type:t.TYPE,mix:this.parent.getParam("ENABLE_LABEL")?[this.parent.settings.classFieldWithLabel,"main-ui-filter-date-group"]:["main-ui-filter-date-group"],label:this.parent.getParam("ENABLE_LABEL")?t.LABEL:"",dragTitle:this.parent.getParam("MAIN_UI_FILTER__DRAG_FIELD_TITLE"),deleteTitle:this.parent.getParam("MAIN_UI_FILTER__REMOVE_FIELD"),tabindex:"TABINDEX"in t?t.TABINDEX:"",name:"NAME"in t?t.NAME:"",deleteButton:true,content:[]};if(BX.type.isPlainObject(t.VALUE.days)){t.VALUE.days=Object.keys(t.VALUE.days).map(function(e){return t.VALUE.days[e]})}var i=t.DAYS.filter(function(e){return t.VALUE.days.some(function(t){return t===e.VALUE})});var n={block:"main-ui-control-field",mix:["main-ui-control-custom-date"],placeholder:t.DAYS_PLACEHOLDER,dragButton:false,content:{block:"main-ui-multi-select",name:t.NAME+"_days",tabindex:"TABINDEX"in t?t.TABINDEX:"",items:t.DAYS,value:i,params:"PARAMS"in t?t.PARAMS:{isMulti:true},valueDelete:true,attrs:{"data-placeholder":t.DAYS_PLACEHOLDER}}};if(BX.type.isPlainObject(t.VALUE.months)){t.VALUE.months=Object.keys(t.VALUE.months).map(function(e){return t.VALUE.months[e]})}var a=t.MONTHS.filter(function(e){return t.VALUE.months.some(function(t){return t===e.VALUE})});var r={block:"main-ui-control-field",mix:["main-ui-control-custom-date"],dragButton:false,content:{block:"main-ui-multi-select",name:t.NAME+"_months",tabindex:"TABINDEX"in t?t.TABINDEX:"",items:t.MONTHS,value:a,params:"PARAMS"in t?t.PARAMS:{isMulti:true},valueDelete:true,attrs:{"data-placeholder":t.MONTHS_PLACEHOLDER}}};if(BX.type.isPlainObject(t.VALUE.years)){t.VALUE.years=Object.keys(t.VALUE.years).map(function(e){return t.VALUE.years[e]})}var l=t.YEARS.filter(function(e){return t.VALUE.years.some(function(t){return t===e.VALUE})});var s={block:"main-ui-control-field",mix:["main-ui-control-custom-date"],dragButton:false,content:{block:"main-ui-multi-select",name:t.NAME+"_years",tabindex:"TABINDEX"in t?t.TABINDEX:"",items:t.YEARS,value:l,params:"PARAMS"in t?t.PARAMS:{isMulti:true},valueDelete:true,attrs:{"data-placeholder":t.YEARS_PLACEHOLDER}}};e.content.push(n);e.content.push(r);e.content.push(s);return BX.decl(e)},_onDateTypeChange:function(t,e){if(this.parent.getPopup().contentContainer.contains(t.node)){var i={};var n=null;var a,r,l,s,o,E,u,c;if(BX.type.isPlainObject(e)&&"VALUE"in e){s=BX.data(t.getNode(),"name");r=t.getParams();if(!BX.type.isPlainObject(r)&&(s.indexOf("_datesel")!==-1||s.indexOf("_numsel")!==-1)){a=t.getNode().parentNode.parentNode;i.TABINDEX=t.getInput().getAttribute("tabindex");i.SUB_TYPES=t.getItems();i.SUB_TYPE=e;i.NAME=BX.data(a,"name");i.TYPE=BX.data(a,"type");E=this.parent.getPreset().getCurrentPresetData();if("FIELDS"in E&&E.FIELDS.length){u=E.FIELDS.filter(function(t){return t.NAME===i.NAME},this);if(u.length){u=u[0];if(s.indexOf("_datesel")!==-1){i.MONTHS=u.MONTHS;i.MONTH=u.MONTH;i.YEARS=u.YEARS;i.YEAR=u.YEAR;i.QUARTERS=u.QUARTERS;i.QUARTER=u.QUARTER;i.ENABLE_TIME=u.ENABLE_TIME;i.YEARS_SWITCHER=u.YEARS_SWITCHER}i.VALUES=u.VALUES}}if(this.parent.getParam("ENABLE_LABEL")){l=BX.Filter.Utils.getByClass(a,this.parent.settings.classFieldLabel);i.LABEL=l.innerText}if(s.indexOf("_datesel")!==-1){n=this.createDate(i)}else{n=this.createNumber(i)}if(BX.type.isArray(this.parent.fieldsList)){c=this.parent.fieldsList.indexOf(a);if(c!==-1){this.parent.fieldsList[c]=n;this.parent.registerDragItem(n)}}this.parent.unregisterDragItem(a);o=BX.Filter.Utils.getByClass(n,this.parent.settings.classField,true);if(BX.type.isArray(o)&&o.length){o.forEach(function(t){t.FieldController=new BX.Filter.FieldController(t,this.parent)},this)}BX.insertAfter(n,a);BX.remove(a)}}}},createNumber:function(t){var e,i,n,a,r,l;var s=this.parent.numberTypes;var o=s.SINGLE;if("SUB_TYPE"in t&&BX.type.isPlainObject(t.SUB_TYPE)){o=t.SUB_TYPE.VALUE;n="PLACEHOLDER"in t.SUB_TYPE?t.SUB_TYPE.PLACEHOLDER:""}t.NAME=t.NAME.replace("_numsel","");e={block:"number-group",type:t.TYPE,mix:this.parent.getParam("ENABLE_LABEL")?[this.parent.settings.classFieldWithLabel,"main-ui-filter-number-group"]:["main-ui-filter-number-group"],label:this.parent.getParam("ENABLE_LABEL")?t.LABEL:"",dragTitle:this.parent.getParam("MAIN_UI_FILTER__DRAG_FIELD_TITLE"),deleteTitle:this.parent.getParam("MAIN_UI_FILTER__REMOVE_FIELD"),tabindex:"TABINDEX"in t?t.TABINDEX:"",value:"SUB_TYPE"in t?t.SUB_TYPE:{},items:"SUB_TYPES"in t?t.SUB_TYPES:[],name:"NAME"in t?t.NAME:"",deleteButton:true,content:[]};if(o!==s.LESS){a={block:"main-ui-control-field",type:t.TYPE,dragButton:false,content:{block:"main-ui-number",mix:["filter-type-single"],calendarButton:true,valueDelete:true,placeholder:n,name:"NAME"in t?t.NAME+"_from":"",tabindex:"TABINDEX"in t?t.TABINDEX:"",value:"VALUES"in t?t.VALUES._from:""}};e.content.push(a)}if(o===s.RANGE){r={block:"main-ui-filter-field-line",content:{block:"main-ui-filter-field-line-item",tag:"span"}};e.content.push(r)}if(o===s.RANGE||o===s.LESS){l={block:"main-ui-control-field",type:t.TYPE,dragButton:false,content:{block:"main-ui-number",calendarButton:true,valueDelete:true,name:"NAME"in t?t.NAME+"_to":"",tabindex:"TABINDEX"in t?t.TABINDEX:"",value:"VALUES"in t?t.VALUES._to:""}}}e.content.push(l);return BX.decl(e)},createDate:function(t){var e,i,n,a,r,l,s,o,E;var u=this.parent.dateTypes;var c=this.parent.additionalDateTypes;var A=u.NONE;if("SUB_TYPE"in t&&BX.type.isPlainObject(t.SUB_TYPE)){A=t.SUB_TYPE.VALUE;l="PLACEHOLDER"in t.SUB_TYPE?t.SUB_TYPE.PLACEHOLDER:""}t.NAME=t.NAME.replace("_datesel","");if("VALUES"in t&&BX.type.isPlainObject(t.VALUES)){var m=Object.keys(t.VALUES);m.forEach(function(e){if(!t.VALUES[e]){t.VALUES[e]=""}})}e={block:"date-group",type:t.TYPE,mix:this.parent.getParam("ENABLE_LABEL")?[this.parent.settings.classFieldWithLabel,"main-ui-filter-date-group"]:["main-ui-filter-date-group"],label:this.parent.getParam("ENABLE_LABEL")?t.LABEL:"",dragTitle:this.parent.getParam("MAIN_UI_FILTER__DRAG_FIELD_TITLE"),deleteTitle:this.parent.getParam("MAIN_UI_FILTER__REMOVE_FIELD"),tabindex:"TABINDEX"in t?t.TABINDEX:"",value:"SUB_TYPE"in t?t.SUB_TYPE:{},items:"SUB_TYPES"in t?t.SUB_TYPES:[],name:"NAME"in t?t.NAME:"",enableTime:"ENABLE_TIME"in t?t.ENABLE_TIME:false,deleteButton:true,content:[]};t.NAME=t.NAME.replace("_datesel","");if(A===u.EXACT){a={block:"main-ui-control-field",type:t.TYPE,dragButton:false,content:{block:"main-ui-date",mix:["filter-type-single"],calendarButton:true,valueDelete:true,placeholder:l,name:"NAME"in t?t.NAME+"_from":"",tabindex:"TABINDEX"in t?t.TABINDEX:"",value:"VALUES"in t?t.VALUES._from:"",enableTime:t.ENABLE_TIME}};e.content.push(a)}if(A===u.NEXT_DAYS||A===u.PREV_DAYS||A===c.PREV_DAY||A===c.NEXT_DAY||A===c.MORE_THAN_DAYS_AGO||A===c.AFTER_DAYS){a={block:"main-ui-control-field",type:t.TYPE,dragButton:false,content:{block:"main-ui-number",mix:["filter-type-single"],calendarButton:true,valueDelete:true,placeholder:l,name:"NAME"in t?t.NAME+"_days":"",tabindex:"TABINDEX"in t?t.TABINDEX:"",value:"VALUES"in t?t.VALUES._days:""}};e.content.push(a)}if(A===u.RANGE){var d={block:"main-ui-filter-range-group",content:[]};i={block:"main-ui-control-field",type:t.TYPE,dragButton:false,content:{block:"main-ui-date",calendarButton:true,valueDelete:true,name:"NAME"in t?t.NAME+"_from":"",tabindex:"TABINDEX"in t?t.TABINDEX:"",value:"VALUES"in t?t.VALUES._from:"",placeholder:l,enableTime:t.ENABLE_TIME}};r={block:"main-ui-filter-field-line",content:{block:"main-ui-filter-field-line-item",tag:"span"}};n={block:"main-ui-control-field",type:t.TYPE,dragButton:false,content:{block:"main-ui-date",calendarButton:true,valueDelete:true,name:"NAME"in t?t.NAME+"_to":"",tabindex:"TABINDEX"in t?t.TABINDEX:"",value:"VALUES"in t?t.VALUES._to:"",placeholder:l,enableTime:t.ENABLE_TIME}};d.content.push(i);d.content.push(r);d.content.push(n);e.content.push(d)}if(A===u.MONTH){if("_month"in t.VALUES&&t.VALUES._month){t.MONTH=t.MONTHS.filter(function(e){return e.VALUE===t.VALUES._month});t.MONTH=t.MONTH.length?t.MONTH[0]:null}if(!t.MONTH){t.MONTH=t.MONTHS[0]}E={block:"main-ui-control-field",dragButton:false,content:{block:"main-ui-select",tabindex:"tabindex"in t?t.tabindex:"",value:t.MONTH,items:t.MONTHS,name:t.NAME+"_month",valueDelete:false}};if("_year"in t.VALUES&&t.VALUES._year){t.YEAR=t.YEARS.filter(function(e){return e.VALUE===t.VALUES._year});t.YEAR=t.YEAR.length?t.YEAR[0]:null}if(!t.YEAR){t.YEAR=t.YEARS[0]}s={block:"main-ui-control-field",dragButton:false,content:{block:"main-ui-select",tabindex:"tabindex"in t?t.tabindex:"",value:t.YEAR,items:t.YEARS,name:t.NAME+"_year",valueDelete:false}};e.content.push(E);e.content.push(s)}if(A===u.QUARTER){if("_year"in t.VALUES&&t.VALUES._year){t.YEAR=t.YEARS.filter(function(e){return e.VALUE===t.VALUES._year});t.YEAR=t.YEAR.length?t.YEAR[0]:null}if(!t.YEAR){t.YEAR=t.YEARS[0]}s={block:"main-ui-control-field",dragButton:false,content:{block:"main-ui-select",tabindex:"tabindex"in t?t.tabindex:"",value:t.YEAR,items:t.YEARS,name:t.NAME+"_year",valueDelete:false}};if("_quarter"in t.VALUES&&t.VALUES._quarter){t.QUARTER=t.QUARTERS.filter(function(e){return e.VALUE===t.VALUES._quarter});t.QUARTER=t.QUARTER.length?t.QUARTER[0]:null}if(!t.QUARTER){t.QUARTER=t.QUARTERS[0]}o={block:"main-ui-control-field",dragButton:false,content:{block:"main-ui-select",tabindex:"tabindex"in t?t.tabindex:"",value:t.QUARTER,items:t.QUARTERS,name:t.NAME+"_quarter",params:t.PARAMS,valueDelete:false}};e.content.push(o);e.content.push(s)}if(A===u.YEAR){if("_year"in t.VALUES&&t.VALUES._year){t.YEAR=t.YEARS.filter(function(e){return e.VALUE===t.VALUES._year});t.YEAR=t.YEAR.length?t.YEAR[0]:null}if(!t.YEAR){t.YEAR=t.YEARS[0]}s={block:"main-ui-control-field",dragButton:false,content:{block:"main-ui-select",tabindex:"tabindex"in t?t.tabindex:"",value:t.YEAR,items:t.YEARS,name:t.NAME+"_year",valueDelete:false}};e.content.push(s)}if(A==="CUSTOM_DATE"){var L=t.SUB_TYPES.filter(function(t){return t.VALUE==="CUSTOM_DATE"});if(L[0]){L=BX.clone(L[0].DECL);if(BX.type.isArray(t.VALUES._days)){L.VALUE.days=t.VALUES._days}if(BX.type.isArray(t.VALUES._month)){L.VALUE.months=t.VALUES._month}if(BX.type.isArray(t.VALUES._year)){L.VALUE.years=t.VALUES._year}var p=this.createCustomDate(L);p.classList.remove("main-ui-filter-wield-with-label");var B=p.querySelector(".main-ui-item-icon-container");if(B){BX.remove(B)}var _=p.querySelector(".main-ui-filter-icon-grab");if(_){BX.remove(_)}e.content.push(p);e.mix.push("main-ui-filter-custom-date-group")}}if(A!==u.NONE&&A!==c.CUSTOM_DATE&&t["YEARS_SWITCHER"]){if("_allow_year"in t.VALUES&&t.VALUES._allow_year){var h=t.YEARS_SWITCHER.ITEMS.filter(function(e){return e.VALUE===t.VALUES._allow_year});h=h.length?h[0]:null;if(h){t.YEARS_SWITCHER.VALUE=h}}var f=this.createSelect(t["YEARS_SWITCHER"]);f.classList.add("main-ui-filter-year-switcher");f.classList.add("main-ui-filter-with-padding");f.classList.remove("main-ui-filter-wield-with-label");B=f.querySelector(".main-ui-item-icon-container");if(B){BX.remove(B)}_=f.querySelector(".main-ui-filter-icon-grab");if(_){BX.remove(_)}if(e.content[e.content.length-1]){if(BX.type.isPlainObject(e.content[e.content.length-1])){if(!BX.type.isArray(e.content[e.content.length-1].mix)){e.content[e.content.length-1].mix=[]}e.content[e.content.length-1].mix.push("main-ui-filter-remove-margin-right")}if(BX.type.isDomNode(e.content[e.content.length-1])){e.content[e.content.length-1].classList.add("main-ui-filter-remove-margin-right")}}requestAnimationFrame(function(){f.previousElementSibling.classList.add("main-ui-filter-remove-margin-right")});e.content.push(f);e.mix.push("main-ui-filter-date-with-years-switcher")}var g=BX.decl(e);var T=[].slice.call(g.querySelectorAll(".main-ui-date-input"));if(T.length>0){T.forEach(function(t){var e=BX.debounce(this.onDateChange,500,this);t.addEventListener("change",e);t.addEventListener("input",e);var i=t.parentNode.querySelector(".main-ui-control-value-delete");if(i){i.addEventListener("click",function(){setTimeout(function(){this.onDateChange({target:t})}.bind(this))}.bind(this))}},this)}return g},onDateChange:function(t){if(e.get(t.target)===t.target.value){return}e.set(t.target,t.target.value);if(t.target.value===""){this.hideDateError(t.target);return}BX.ajax.runComponentAction("bitrix:main.ui.filter","checkDateFormat",{mode:"ajax",data:{value:t.target.value}}).then(function(e){if(!e.data.result){this.showDateError(t.target);return}this.hideDateError(t.target)}.bind(this))},showDateError:function(e){e.style.borderColor="#FF5752";if(t.has(e)){BX.remove(t.get(e))}var i=BX.create("div",{attrs:{class:"main-ui-filter-error-message",title:this.parent.params["MAIN_UI_FILTER__DATE_ERROR_TITLE"]},text:this.parent.params["MAIN_UI_FILTER__DATE_ERROR_LABEL"]+" "+BX.message("FORMAT_DATE")});t.set(e,i);BX.insertAfter(i,e);e.dataset.isValid=false},hideDateError:function(e){e.style.borderColor=null;if(t.has(e)){BX.remove(t.get(e))}e.dataset.isValid=true}}})();
//# sourceMappingURL=fields.map.js